#!/usr/bin/env python
import telnetlib
import sys

def telwr(tn,s):
    tn.write(s+"\n")
    print tn.read_until("#")

host = sys.argv[1]
user = "g"
passwd = "p"
print host
tn = telnetlib.Telnet(host)
#tn.set_debuglevel(5)
#print tn.read_all()
print tn.read_until("ername: ")
tn.write(user+"\n")
print tn.read_until("sword: ")
tn.write(passwd+"\n")
print tn.read_until("#")

#telwr(tn,"conf t")
#telwr(tn,"int rang g0/1-48")
#telwr(tn,"no udld port agg")
#telwr(tn,"end")
#telwr(tn,"wr me")
tn.interact()

#tn.close()
